using System.Text.Json.Serialization;

namespace Sage.CloudStorage.Qiniu.Models
{
    /// <summary>
    /// 持久化数据处理状态查询结果
    /// </summary>
    public class PrefopResult
    {
        /// <summary>
        /// 状态码，0表示成功
        /// </summary>
        [JsonPropertyName("code")]
        public int Code { get; set; }

        /// <summary>
        /// 持久化处理ID
        /// </summary>
        [JsonPropertyName("id")]
        public string Id { get; set; } = string.Empty;

        /// <summary>
        /// 处理状态，0-成功，1-等待处理，2-正在处理，3-处理失败，4-通知提交失败
        /// </summary>
        [JsonPropertyName("status")]
        public int Status { get; set; }

        /// <summary>
        /// 处理进度，范围为1-100，表示进度百分比
        /// </summary>
        [JsonPropertyName("progress")]
        public int Progress { get; set; }

        /// <summary>
        /// 处理结果数组
        /// </summary>
        [JsonPropertyName("items")]
        public PrefopResultItem[]? Items { get; set; }

        /// <summary>
        /// 错误信息，仅当查询失败时有值
        /// </summary>
        [JsonPropertyName("error")]
        public string? Error { get; set; }
    }

    /// <summary>
    /// 持久化数据处理结果项
    /// </summary>
    public class PrefopResultItem
    {
        /// <summary>
        /// 命令，即数据处理指令
        /// </summary>
        [JsonPropertyName("cmd")]
        public string Cmd { get; set; } = string.Empty;

        /// <summary>
        /// 处理状态码，0表示成功
        /// </summary>
        [JsonPropertyName("code")]
        public int Code { get; set; }

        /// <summary>
        /// 处理结果描述
        /// </summary>
        [JsonPropertyName("desc")]
        public string? Desc { get; set; }

        /// <summary>
        /// 处理错误信息，仅当处理失败时有值
        /// </summary>
        [JsonPropertyName("error")]
        public string? Error { get; set; }

        /// <summary>
        /// 处理结果，例如目标文件的哈希值
        /// </summary>
        [JsonPropertyName("hash")]
        public string? Hash { get; set; }

        /// <summary>
        /// 处理结果保存的目标空间
        /// </summary>
        [JsonPropertyName("bucket")]
        public string? Bucket { get; set; }

        /// <summary>
        /// 处理结果保存的目标文件名
        /// </summary>
        [JsonPropertyName("key")]
        public string? Key { get; set; }
    }
}